/*
*此文件生成Mybatis注解java文件
*/

package ${de.packageName}.entity;
import java.io.Serializable;
import java.util.Date;
import org.springframework.format.annotation.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.alibaba.fastjson.annotation.JSONField;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.GeneratedValue;
import javax.persistence.*;
<#if columnEntity.escape=="true">	
import org.apache.commons.lang.StringEscapeUtils;
</#if>

@Entity
	<#if de.customSql==false>
@Table(name="${de.tableName}")
	</#if>
public class ${entityNam} implements Serializable {

<#list columnEntitys as columnEntity>
	/**
	* ${columnEntity.entityColumnComment}
	*/
  <#if columnEntity.key==true>
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "UUID")
	//@GeneratedValue(strategy = GenerationType.AUTO, generator = "SeqGen")
	//@SequenceGenerator(name = "SeqGen", sequenceName = "SEQ_GLOBAL_KEY", allocationSize = 1)
	</#if>	
  	<#if columnEntity.uiTyp=="datetimebox">
  	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")//从前台传的数据可以直接转换成Date
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")//可以把后台数据换成JSON传到前台
	</#if>
	<#if columnEntity.uiTyp=="datebox">
	@DateTimeFormat(pattern = "yyyy-MM-dd")//从前台传的数据可以直接转换成Date
	@JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")//可以把后台数据换成JSON传到前台
	</#if>
	@Column(name = "${columnEntity.columnNam}")
	private ${columnEntity.entityColumnTyp} ${columnEntity.entityColumnNam};
    </#list>

	/** default constructor */
	public ${entityNam}(){
	}

	<#list columnEntitys as columnEntity>
		<#if columnEntity.key==true>
	public ${entityNam}(${columnEntity.entityColumnTyp} id){
		this.${columnEntity.entityColumnNam}=id;
	}
		</#if>
	</#list>
	/** full constructor */
	public ${entityNam}(
		<#list columnEntitys as columnEntity>
		${columnEntity.entityColumnTyp} ${columnEntity.entityColumnNam}<#if columnEntity_has_next>,</#if>
		</#list>){
	     <#list columnEntitys as columnEntity>
		this.${columnEntity.entityColumnNam}=${columnEntity.entityColumnNam};
		</#list>
	}

	<#list columnEntitys as columnEntity>
	/*
	* ${columnEntity.entityColumnComment}
	*/
	<#if columnEntity.key==true>
	public ${columnEntity.entityColumnTyp} get${columnEntity.entityColumnMethodNam}(){
		return this.${columnEntity.entityColumnNam};
	}
	public void set${columnEntity.entityColumnMethodNam}(${columnEntity.entityColumnTyp} ${columnEntity.entityColumnNam}){
		    <#if columnEntity.entityColumnTyp=="java.lang.String">
		    //string类型的主键，如果为空字符串，设置为null,否则mybatis插入出错
		this.${columnEntity.entityColumnNam}="".equals(${columnEntity.entityColumnNam})?null:${columnEntity.entityColumnNam};
			   <#else>  
		this.${columnEntity.entityColumnNam}=${columnEntity.entityColumnNam};
			</#if>	
	}
		<#else>  
		<#if columnEntity.escape=="true">	
		//有些字段可能会输入html字符，防止客户输入，特转码
	public ${columnEntity.entityColumnTyp} get${columnEntity.entityColumnMethodNam}(){
		return StringEscapeUtils.unescapeHtml(this.${columnEntity.entityColumnNam});
	}
	
	<#if columnEntity.noCamel==true>
	//有些字段第二个字符为下划线，这样出来的驼峰字段，阿里的JSON转换会无法赋值，可以在set上设置@JSONField，但SpringMvc直接转换无问题
	@JSONField(name="${columnEntity.entityColumnNam}")
	</#if>
	public void set${columnEntity.entityColumnMethodNam}(${columnEntity.entityColumnTyp} ${columnEntity.entityColumnNam}){
		this.${columnEntity.entityColumnNam}=${columnEntity.entityColumnNam}==null?null: HdEscapeUtil.escapeHtml(${columnEntity.entityColumnNam});
	}
		<#else>  
	public ${columnEntity.entityColumnTyp} get${columnEntity.entityColumnMethodNam}(){
		return this.${columnEntity.entityColumnNam};
	}
	<#if columnEntity.noCamel==true>
	//有些字段第二个字符为下划线，这样出来的驼峰字段，阿里的JSON转换会无法赋值，可以在set上设置@JSONField，但SpringMvc直接转换无问题
	@JSONField(name="${columnEntity.entityColumnNam}")
	</#if>
	public void set${columnEntity.entityColumnMethodNam}(${columnEntity.entityColumnTyp} ${columnEntity.entityColumnNam}){
		this.${columnEntity.entityColumnNam}=${columnEntity.entityColumnNam};
	}
		</#if>
	</#if>
	
	<#if columnEntity.entityColumnTyp=="java.util.Date">

	</#if>	
	
</#list>
}